package com.hzit.hzb.core.controller.admin;


import com.hzit.common.result.R;
import com.hzit.hzb.base.util.JwtUtils;
import com.hzit.hzb.core.pojo.entity.BorrowInfo;
import com.hzit.hzb.core.pojo.vo.BorrowInfoApprovalVO;
import com.hzit.hzb.core.service.BorrowInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author hbxfwf
 * @since 2024-08-27
 */
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {

	@Autowired
	private BorrowInfoService borrowInfoService;

	//1. 查看所有的借款列表
	@GetMapping("/list")
	public R list(){
		List<BorrowInfo> borrowInfos = borrowInfoService.selectList();
		return R.ok().data("list",borrowInfos);
	}

	// 2. 根据借款id查看借款人及借款信息的详细数据
	@GetMapping("/show/{id}")
	public R show(@PathVariable("id") Integer id){
		Map<String, Object> resultMap = borrowInfoService.show(id);
		return R.ok().data("borrowInfoDetail",resultMap);
	}

	// 3. 借款审核
	@PostMapping("approval")
	public R approval(@RequestBody BorrowInfoApprovalVO vo){
		borrowInfoService.approval(vo);
		return R.ok().message("审批完成。");
	}
}

